#include<iostream>
#include<map>
using namespace std;

int main() {
	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	map<int, int> m;
	while(n--){
		int t;
		cin>>t;
		m[t]++;
	}
	int k;cin>>k;int flag=1;
	while(k--){
		int s;
		cin>>s;
		if(flag){
			cout<<m[s];flag=0;
		}else{
			cout<<" "<<m[s];
		}
	}

}